import { createRouter, createWebHashHistory } from "vue-router";

export default createRouter({
  //设置为history模式
  history: createWebHashHistory(),
  routes: [
    {
      path: "/home", //配置默认路由
      name: "home", //路由名
      component: () => import("@/pages/home/index.vue"), //引入该路由使用的组件
    },
    {
      path: "/", //配置默认路由
      redirect: "/home",
    },
    {
      path: "/error", //配置默认路由
      name: "error", //路由名
      component: () => import("@/pages/error/index.vue"), //引入该路由使用的组件
    },
  ],
  //切换路由后回到顶部
  scrollBehavior() {
    return { left: 0, top: 0 };
  },
});
